package message

import (
	"common/mildware"
	"common/router"
	"github.com/gin-gonic/gin"
	"project/pkg/dao/mysql"
	"project/pkg/dao/redis"
)

type MRouter struct {
}
type MHandler struct {
	M mysql.Mysql
	R redis.Redis
}

func NewMHandler() *MHandler {
	return &MHandler{
		M: mysql.NewMysql(),
		R: redis.NewRedis(),
	}
}
func init() {
	router.AddRouter(new(MRouter))
}
func (MRouter) Router(e *gin.Engine) {
	handler := NewMHandler()
	message := e.Group("message")
	message.POST("/add", handler.AddMessageToUser)
	message.POST("/del", handler.DelMessageToUser)
	message.POST("/update", handler.UpdateMessageStatus)
	message.Use(mildware.JWTAuthMiddleware())
	message.GET("/user/from", handler.SearchByForm)
	message.GET("/user/to", handler.SearchByTo)
}
